CODE!!!!



I created a health manager for the player so the UI can indicate the players health.

I've improved a lot over the past years so if I would recreate this I would change the health icon list, because now they are all dragged in individually. I would now create and array that just enters [child] and would indicate current health to the child position in the array. But since I was still learning when this project was created this is a good working script for a health manager.

using UnityEngine.SceneManagement;

  public class PlayerHealth : MonoBehaviour
  {
  
      public int maxHealth = 100;
      public int currentHealth;
  
      public int maxArmor = 100;
      public int currentArmor;
  
      public HealthBar healthBar;
      public ArmorBar armorBar;
  
      public bool hasArmor;
  
      public GameObject lastHitter;
      Statistieken statistieken;
  
      private void Start()
      {
          maxHealth = maxHealth + PlayerPrefs.GetInt("Healt", 0);
          maxArmor = maxArmor + PlayerPrefs.GetInt("Armor", 0);
          statistieken = FindObjectOfType<Statistieken>();
  
          armorBar.setMaxArrmor(maxArmor);
  
          armorBar.SetArrmor(0);
  
          currentHealth = maxHealth;
          currentArmor = 0;
  
          hasArmor = true;
      }
  
      public void TakeDamage(int damage)
      {
          if (hasArmor == true)
          {
              currentArmor -= damage;
              armorBar.SetArrmor(currentArmor);
              CheckArmor();
          }
          else
          {
              currentHealth -= damage;
              healthBar.Sethealth(currentHealth);
              CheckHealth();
          }
      }
  
      public void ChangeHealth(int amount)
      {
          currentHealth += amount;
          healthBar.Sethealth(currentHealth);
          CheckHealth();
      }
  
      public void AdArmor(int amount)
      {
          hasArmor = true;
          currentArmor += amount;
          armorBar.setMaxArrmor(currentArmor);
          CheckArmor();
      }
  
      private void CheckHealth()
      {
          if (currentHealth >= 100)
          {
              currentHealth = 100;
          }
          if (currentHealth <= 0)
          {
              statistieken.Killer = lastHitter;
              SceneManager.LoadScene("Game Over");
              currentHealth = 0;
          }
      }
      private void CheckArmor()
      {
          if (currentArmor >= 100)
          {
              currentArmor = 100;
          }
          if (currentArmor <= 0)
          {
              currentArmor = 0;
              hasArmor = false;
          }
      }
  }



Cutscenes and animation down here.



In this project i went all in on the look of the game. cutscenes, animation, pickups, level design and Particles.

Random Image



I recreated the tutorial level first for the first level with an intro cutscene, informational cutscene and outro cutscene.



I also polished some door by creating animations for it when you get close so the game gives more feeling when playing it. I made an ontrigger collider on the door that when the player enters the animation state would turn true and open. Ever since this animation I also found out that animation work in the global world of the scene, what I mean with this is that I made multiple animation for doors since some door where in different positions and rotations. I found out that by creating the animation inside the child of an parent it would use the local space the parent provides. this fixed a lot since you only have to move or rotate the parent and the child will always stay the same as it's local animation/position/rotation.



I created some particles and lights around the map an the player since we've chosen a darker theme for the map I gave the player to have the ability to look around with a flashlight. Also I gave the player bullets a small particle explosion to indicate that the bullet had collision.



Last I created a cutscene for the final boss indicating you entered the final area and a showcase of the boss and it's weapon.





Date: Jul 5, 2021

– Project: Twin Stick Shooter

– Duration: 6 Week

– Team: 2 Devs, 2 Artists

My Part: Movement, Camera Movement, Health Manager, Mini Games, Boss Level Shields, Animations, Cutscenes, Level Design, Particles, Pickups

Summary:

We made a twin stick shooter for pc as our end project for year 1. Our idea was to make a game that played in space, you are a little robot stuck in a broken ship. You make your way thru the ship but are stopped by enemy robots. Shoot, Move and complete puzzles to make your way to an escape pod